/**
 * 
 */
package ar.com.sebasoft.prestalibro.business;

import android.content.Context;
import ar.com.sebasoft.prestalibro.model.Socio;
import ar.com.sebasoft.prestalibro.persistence.SocioDBManager;
import ar.com.sebasoft.prestalibro.util.EncryptionUtil;
import ar.com.sebasoft.prestalibro.util.impl.EncryptionMD5Strategy;
import ar.com.sebasoft.prestalibro.view.util.SessionInViewManager;

/**
 * @author SebaSOFT
 * 
 */
public class SocioBusiness {

	private SessionInViewManager session = null;
	private SocioDBManager socioDB = null;

	public SocioBusiness(Context ctx) {
		this.session = SessionInViewManager.getInstance(ctx);
		this.socioDB = new SocioDBManager(ctx);
	}

	public Socio loginByEmailAndClave(String email, String clave) {
		Socio res = null;

		res = this.socioDB.getSocioByEmailAndClave(email, this.encryptKey(clave));

		return res;
	}

	private String encryptKey(String clave) {

		// MD5 Strategy
		EncryptionUtil eUtil = new EncryptionUtil(new EncryptionMD5Strategy());

		return eUtil.encryptKey(clave);
	}
}
